﻿using System;
using System.Runtime.Serialization;

namespace Luna.Connectors.ZohoCRM
{
    [Serializable]
    public sealed class ZohoResponseException : Exception
    {
        private const string ERROR_CODE = "ErrorCode";

        internal ZohoResponseException(ZohoResponse P_Response)
            : base(P_Response.Message)
        {
            ErrorCode = P_Response.Code;
        }

        internal ZohoResponseException(SerializationInfo info, StreamingContext context)
        {
            ErrorCode = info.GetString(ERROR_CODE);
        }

        public string ErrorCode { get; private set; }

        public override void GetObjectData(SerializationInfo info, StreamingContext context)
        {
            info.AddValue(ERROR_CODE, ErrorCode);
            base.GetObjectData(info, context);
        }
    }
}